﻿<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>编译</title>
	<meta charset="utf-8" />
	<script src="../lib/Query.js"></script>
	<script src="../lib/Coro.js"></script>
</head>
<body>
	<h1>Output：</h1>
	<img src="images/loading.gif" />
	<div id="divValue"></div>

	<div id="console" style="border:1px solid #ddd; padding:20px; border-radius:20px;"></div>
	<script>
		var console = {
			log : function(msg){
				var div = document.createElement("div");
				div.innerText = msg;
				document.getElementById("console").appendChild(div);
			}
		}
	</script>

	<script type="text/coro">
		console.log("hello");
		var hello;
		coro("hello");

		console.log("\n");
		var hello = {};
		console.log("hello.world");
		coro("hello.world");

		console.log("\n");
		var a={b:{c:{d:{}}}};
		console.log("a.b.c.d");
		coro("a.b.c.d");

		console.log("\n");
		var a=function(){ return { b:function(){ return { c:function(){} } } } };
		console.log("a().b().c()");
		coro("a().b().c()");

		console.log("\n");
		console.log("(1);");
		coro("(1);");

		console.log("\n");
		var hello,world;
		console.log("(hello,world);");
		coro("(hello,world);");

		console.log("\n");
		var hello,world={},a,b;
		console.log("(hello=a,world.c=b);");
		coro("(hello=a,world.c=b);");

		console.log("\n");
		console.log("(function(hello, world){})");
		coro("(function(hello, world){})");

		console.log("\n");
		console.log("(function(hello, world){ })()");
		coro("(function(hello, world){ })()");

		console.log("\n");
		console.log("(hello,world)=>{}");
		coro("(hello,world)=>{}");

		console.log("\n");
		console.log("var hello; (function(){ var a,b c; }); var world");
		coro("var hello; (function(){ var a,b c; }); var world");

		console.log("\n");
		console.log("var hello; ()=>{ var a,b c; }; var world");
		coro("var hello; ()=>{ var a,b c; }; var world");

		console.log("\n");
		console.log("for(var i = 0; i < 10; i++){}");
		coro("for(var i = 0; i < 10; i++){}");

		console.log("\n");
		var i = 1;
		console.log("if(i > 10){} else if(i < 10){} else {}");
		coro("if(i > 10){} else if(i < 10){} else {}");

		console.log("\n");
		var i = 1;
		console.log("switch(i){ case \"hello\": break; default: break; }");
		coro("switch(i){ case \"hello\": break; default: break; }");

		console.log("\n");
		var items = [1,2,3,4];
		console.log("for(var item in items){}");
		coro("for(var item in items){}");

		console.log("\n");
		var items = [1,2,3,4];
		console.log("for(var item of items){}");
		coro("for(var item of items){}");

		console.log("\n");
		console.log("while(false){}");
		coro("while(false){}");

		console.log("\n");
		console.log("var arr = [1,2,3,4];");
		coro("var arr = [1,2,3,4];");

		console.log("\n");
		console.log("[1].toString().world;");
		coro("[1].toString().world;");

		console.log("\n");
		console.log("[1].toString().hello = 123;");
		coro("[1].toString().hello = 123;");

		console.log("\n");
		console.log("[1][0]");
		coro("[1][0]");

		console.log("\n");
		console.log("[1][0] = 2");
		coro("[1][0] = 2");

		console.log("\n");
		var hello = [function(){}];
		console.log("hello[0]()");
		coro("hello[0]()");

		console.log("\n");
		var hello = [1];
		console.log("hello[0] = 2");
		coro("hello[0] = 2");

		console.log("\n");
		var hello = {a:{a:"b"}}, world = {a:"a"};
		console.log("hello[world.a][world.a]");
		coro("hello[world.a][world.a]");

		console.log("\n");
		var o = {name:"tom", hello:function(){ console.log("hello, my name is " + this.name); } };
		console.log("o.hello()");
		coro("o.hello()");

		
		var value = 0, abc = true;
		var div = document.getElementById("divValue");
		while(abc){
			new Promise(function(resolve, reject){
				div.innerText = (value++);
				setTimeout(function(){ resolve(); },100);
			});
		};
	</script>
	<script>
		coro();
	</script>
</body>
</html>
